layui.use(['table', 'layer', 'jquery', 'form', 'laydate', 'element', 'upload', 'carousel'], function () {
    let table = layui.table,
        $ = layui.jquery,
        form = layui.form,
        layer = layui.layer,
        laydate = layui.laydate,
        element = layui.element,
        upload = layui.upload,
        carousel = layui.carousel;


    //日期时间选择器(从业时间开始)
    laydate.render({
        elem: '#congYeShiJianShi'
        , type: 'date'
    });
    //日期时间选择器（从业时间结束）
    laydate.render({
        elem: '#congYeShiJianZhong'
        , type: 'date'
    });
    //日期时间选择器（离职时间开始）
    laydate.render({
        elem: '#liZhiShiJianShi'
        , type: 'date'
    });
    //日期时间选择器（离职时间结束）
    laydate.render({
        elem: '#liZhiShiJianZhong'
        , type: 'date'
    });


    // 下拉框回显
    // 页面下拉框进行回显(公司信息)
    $.ajax({
        url: '/shenBaoGeShui/selectRenYuanXinXiXiaLaHuiXian',
        type: 'get',
        dataType: 'json',
        success: function (data) {
            console.log(data)
            if (data.code == 200) {
                //公司回显
                // for (let i = 0; i < data.gongSi.length; i++) {
                //     $("#companyName").append("<option value='" + data.gongSi[i].daiLiShangCid + "'>" + data.gongSi[i].companyName + "</option>");
                // }
                //员工回显
                for (let j = 0; j < data.yuanGong.length; j++) {
                    $("#xingMing").append("<option >" + data.yuanGong[j].xingMing + "</option>");
                    $("#dianHuaHaoMa").append("<option >" + data.yuanGong[j].tel + "</option>");
                    $("#zhengJianHaoMa").append("<option >" + data.yuanGong[j].zhengZhaoHaoMa + "</option>");
                }
                form.render();
            } else {
                post_flag = false;
            }

        }
    })


    // 页面搜索按钮
    $('#yemiansousuo').click(function () {
        let companyName = $("#companyName").val();//公司名称
        let zhengZhaoHaoMa = $("#zhengJianHaoMa").val();//证件号码
        let tel = $("#dianHuaHaoMa").val();//员工电话
        let isZuoZhang = $("#shiFouZuoZhang").val();//是否做账
        let xingMing = $("#xingMing").val();//姓名
        let yuanGongBuMen = $("#yuanGongBuMen").val();//员工部门
        let renYuanZhuangTai = $("#renYuanZhuangTai").val();//人员状态
        let isShenBao = $("#shiFouShenBao").val();//是否申报
        let congYeShiJianShi = $("#congYeShiJianShi").val();//从业时间（开始）
        let congYeShiJianZhong = $("#congYeShiJianZhong").val();//从业时间（结束）
        let liZhiShiJianShi = $("#liZhiShiJianShi").val();//离职时间（开始）
        let liZhiShiJianZhong = $("#liZhiShiJianZhong").val();//离职时间（结束）
        let gongZiShi = $("#gongZiShi").val();//员工工资（开始）
        let gongZiZhong = $("#gongZiZhong").val();//员工工资（结束）

        console.log("公司名称：" + companyName)
        console.log("证件号码：" + zhengZhaoHaoMa)
        console.log("电话：" + tel)
        console.log("是否做账：" + isZuoZhang)
        console.log("姓名：" + xingMing)
        console.log("员工部门：" + yuanGongBuMen)
        console.log("人员状态：" + renYuanZhuangTai)
        console.log("是否申报：" + isShenBao)
        console.log("从业时间（开始）：" + congYeShiJianShi)
        console.log("从业时间（结束）：" + congYeShiJianZhong)
        console.log("离职时间（开始：" + liZhiShiJianShi)
        console.log("离职时间结束：" + liZhiShiJianZhong)
        console.log("低工资：" + gongZiShi)
        console.log("高工资：" + gongZiZhong)
        //主页面表格
        table.reload('renYuxnXiXin_table', {
            url: '/shenBaoGeShui/selectGeShuiRenYuanXinXi'
            ,
            where: {
                "companyName": companyName,
                "zhengZhaoHaoMa": zhengZhaoHaoMa,
                "tel": tel,
                "isZuoZhang": isZuoZhang,
                "xingMing": xingMing,
                "yuanGongBuMen": yuanGongBuMen,
                "renYuanZhuangTai": renYuanZhuangTai,
                "isShenBao": isShenBao,
                "congYeShiJianShi": congYeShiJianShi,
                "congYeShiJianZhong": congYeShiJianZhong,
                "liZhiShiJianShi": liZhiShiJianShi,
                "liZhiShiJianZhong": liZhiShiJianZhong,
                "gongZiShi": gongZiShi,
                "gongZiZhong": gongZiZhong,
            }
            ,
            page: {curr: 1}
        });
    });


    //表格回显
    table.render({
        elem: '#renYuxnXiXin_table'
        , url: '/shenBaoGeShui/selectGeShuiRenYuanXinXi'
        // , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
        // , where: {zuoZhangShenBaoId: keHuId}
        , cols: [[
            {title: '序号', fixed: 'left', type: 'numbers', width: "5%"}
            , {field: 'companyName', align: 'left', title: '客户公司名称', width: "23%"}
            , {field: 'xingMing', align: 'left', title: '姓名', width: "8%"}
            , {field: 'yuanGongGongZi', align: 'left', title: '员工工资', width: "8%"}
            , {field: 'xingBie', align: 'left', title: '姓别', width: "8%"}
            , {field: 'chuShengRiQi', align: 'left', title: '出生日期', width: "12%"}
            , {field: 'zhengZhaoLeiXing', align: 'left', title: '证照类型', width: "9%"}
            , {field: 'zhengZhaoHaoMa', align: 'left', title: '证照号码', width: "15%"}
            , {field: 'tel', align: 'left', title: '电话', width: "15%"}
            , {field: 'guoJiDiQu', align: 'left', title: '国籍', width: "8%"}
            , {
                field: 'renYuanZhuangTai', align: 'left', title: '人员状态', width: "8%",
                templet: function (obj) {
                    if (obj.renYuanZhuangTai == 0) {
                        return "离职";
                    }
                    if (obj.renYuanZhuangTai == 1) {
                        return "在职";
                    }
                }
            }
            , {
                field: 'yuanGongBuMen', align: 'left', title: '员工部门', width: "8%",
                templet: function (obj) {
                    if (obj.yuanGongBuMen == 1) {
                        return "管理";
                    }
                    if (obj.yuanGongBuMen == 2) {
                        return "销售";
                    }
                    if (obj.yuanGongBuMen == 3) {
                        return "财务"
                    } else {
                        return "未设置"
                    }
                }
            }
            , {field: 'liZhiTime', align: 'left', title: '离职时间', width: "12%"}
            , {field: 'congYeLeiXing', align: 'left', title: '从业类型', width: "8%"}
            , {field: 'congYeRiQi', align: 'left', title: '从业日期', width: "12%"}
            , {
                field: 'isShenBao',
                align: 'left',
                title: '是否申报',
                width: "7%",
                templet: function (obj) {
                    if (obj.isShenBao == 0) {
                        return "不申报";
                    }
                    if (obj.isShenBao == 1) {
                        return "申报";
                    }
                }
            }, {
                field: 'isZuoZhang',
                align: 'left',
                title: '是否做账',
                width: "7%",
                templet: function (obj) {
                    if (obj.isZuoZhang == 0) {
                        return "不做账";
                    }
                    if (obj.isZuoZhang == 1) {
                        return "做账";
                    }
                }
            }
            , {field: 'buZaiShenBaoTime', align: 'left', title: '不再申报时间', width: "12%"}
            , {field: 'jiGouName', align: 'left', title: '所属代理商', width: "15%"}
            , {field: 'tianJiaRenName', align: 'left', title: '提交人', width: "8%"}
            , {field: 'gengXinTime', align: 'left', title: '数据更新时间', width: "12%"}
            // , {fixed: 'right', title: '操作', toolbar: '#zhongZhiDemo', width: "8%"}
        ]]
        , page: true

    });


})
